<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //去除数组1[1,2,3,4,5]与数组2[1,3,5,7,9]中共同的元素

    
    let shu1=[1,2,3,4,5];let shu2=[1,3,5,7,9]
    for (let i = 0; i < shu1.length; i++) {
        for (let j = 0; j < shu2.length; j++) {
            if (shu1[i] == shu2[j]) {
                shu1[i] = '';
                shu2[j] = '';
                break;
            }
        }
    }
    for(let i=0;i<shu1.length;i++){
        if(shu1[i] === ''){
            shu1.splice(i,1);
            i--; 
        }
    }
    for(let i=0;i<shu2.length;i++){
        if(shu2[i] === ''){
            shu2.splice(i,1);
            i--;
        }
    }
    console.log(shu1);
    console.log(shu2);
    
</script>
</html>